38

Algorithms for Binary Neural Networks

and that real-valued neurons may not even be required in deep neural networks, which is

comparable to the idea behind biological neural networks.

Additionally, an efficient method to examine the interpretability of deep neural networks

is to reduce the bit width of a particular layer and examine its impact on accuracy. Numerous

works [199, 159] investigate how sensitive various layers are to binarization. In common

BNNs, the first and last layers should, by default, be kept at higher precision. This means

that these layers are more crucial for predicting neural networks. This section attempts to

state the nature of binary neural networks by introducing some representative work.

3.2

BNN: Binary Neural Network

Given an N-layer CNN model, we denote its weight set as W = {wn}N

n=1 and the input

feature map set as A = {an

in}N

n=1. The wnRCn

out×Cn

in×Kn×Kn and an

in RCn

in×W n

in×Hn

in

are the convolutional weight and the input feature map in the n-th layer, where Cn

in, Cn

out

and Kn, respectively, represent the input channel number, the output channel number, and

the kernel size. In addition, W n

in and Hn

in are the width and height of the feature maps.

Then, the convolutional outputs an

out can be technically formulated as:

an

out = wnan

in,

(3.1)

whererepresents the convolution operation. In this book, we omit the non-linear function

for simplicity. Following the prior works [48, 99], BNN intends to represent wn and an in a

binary discrete set as:

B := {−1(0), +1}.

Thus, the 1-bit format of wn and an is respectively bwn BCn

out×Cn

in×Kn×Kn and ban

in

BCn

in×W n

in×Hn

in such that the efficient XNOR and Bit-count instructions can approximate

the floating-point convolutional outputs as:

an

out bwnban

in,

(3.2)

whererepresents channel-wise multiplication anddenotes XNOR and Bit-count instruc-

tions.

However, this quantization mode will cause the output amplitude to increase dramati-

cally, different from the full precision convolution calculation, and cause the homogenization

of characteristics [199]. Several novel objects are proposed to address this issue, which will

be introduced in the following.

3.3

XNOR-Net: Imagenet Classification Using Binary

Convolutional Neural Networks

The scaling factor was first proposed by XNOR-Net [199] to solve this problem. The weights

and the inputs to the convolutional and fully connected layers in XNOR-Nets are approxi-

mated with binary values B.